package com.ljsw.adapter;

import java.util.ArrayList;

import com.bumptech.glide.Glide;
import com.ljsw.activity.R;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

/**
 * 拍照功能适配器
 * 作者: 石锚
 * 版本: 1.0
 * 日期: 2015-10-13
 */
public class PaiZhaoAdapter extends BaseAdapter{
	private ArrayList<String> list = new ArrayList<String>();
	private Context context;

	public PaiZhaoAdapter(ArrayList<String> list, Context context) {
		super();
		this.list = list;
		this.context = context;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	public View getView(int arg0, View arg1, ViewGroup arg2) {
		ViewHolder holder;
		if(arg1==null){
			holder = new ViewHolder();
			arg1 = LayoutInflater.from(context).inflate(R.layout.paizhao_list_item, null);
			holder.image = (ImageView) arg1.findViewById(R.id.paizhao_image);
			arg1.setTag(holder);
		}else{
			holder = (ViewHolder) arg1.getTag();
		}
		Glide.with(context).load(list.get(arg0)).into(holder.image);
		return arg1;
	}
	
	static class ViewHolder{
		private ImageView image;
	}
}
